clear all 

/****************************************************************************************************
		
Replication file 2 out of 3 for:
"The Intractability of Islamist Insurgencies: Islamist Rebels and the Recurrence of Civil War"
Desirée Nilsson & Isak Svensson
International Studies Quarterly
Last updated: 20 April 2021
Note that dyadep 18502 has been replaced with 28502 due to an error in original termination data
***************************************************************************************************/


*To run the do-file you need to install the following:

*1. To generate summary statistics:
//ssc install unique

*2. To generate graphs:
//ssc install blindschemes, replace all

*3. To generate tables: 
//ssc install outreg
//ssc install outreg2

****************************************************************************************************
 
use "Recurrence-data-ISQ.dta"
sort dyadid year


************************************************
* STSET FOR SURVIVAL ANALYSIS RECURRENCE as DV
************************************************

stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)


************************************************
* STSET FOR SURVIVAL ANALYSIS NEW-RECURRENCE as DV
************************************************

//stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)


************************************************
* CREATE LABELS
************************************************

label variable firstrecur "Recurrence"
label variable newrecur1 "Recurrence-new"
label variable islamist "Islamist claim"
label variable territory "Territory"
label variable duration "Duration"
label variable intensitylevel "War"
label variable number_group "Number of groups"
label variable transstart "Transnational constituency"
label variable forinvstart "Foreign involvement"
label variable strongstart "Strong rebels"
label variable pa "Peace agreement"
label variable ca "Ceasefire agreement"
label variable lowcease "Low activity"

label variable govv "Government victory"
label variable rebv "Rebel victory"
label variable pko "Peacekeeping presence"
label variable anostart "Anocracy"
label variable lngdppcstart "GDP per capita"
label variable lnpopstart "Population"
label variable muslimajstart "Muslim majority"
label variable oilstart "Oil"
label variable youthstartap "Youth bulge/adult pop."
label variable muslimid "Muslim identity"

label variable foreignfighter "Foreign fighters"
label variable govmilsupport "Government support"
label variable leftist "Leftist"
label variable nonislamistrel "Non-Islamist religious claims"
label variable muslimid "Muslim identity"

label variable anocracy "Anocracy over time"
label variable lngdppc "GDP pc over time"
label variable lnpop "Population over time"
label variable secsup_govgov "Government secondary support"
label variable rebext "Rebel support"


************************************************
* CONTROL VARIABELS
************************************************

global X1 territory strongstart oilstart youthstartap muslimajstart
global X2 _yrs _yrs_sq _yrs_cu


************************************************
* DESCRIPTIVE STATISTICS
************************************************

*islamist conflicts*
unique dyadid if islamist==1 | islamist==0 
*367

unique dyadid if islamist==1 
*53*

unique dyadid if islamist==0 
*314

unique dyadid if firstrecur==1 & islamist==1 
*20 out of 53

unique dyadid if firstrecur==1 & islamist==0
*78 out of 314

*number of recurrences-new and recurrences with Islamist actors*
count if newrecur1==1 
*80
count if newrecurislamist1==1
*23

count if firstrecur==1
*172
count if firstrecur==1 & islamist==1
*35

*after 15 years of analysis time*
unique dyadid if _t>15 & islamist==1


************************************************
* TABLE A2
************************************************

su firstrecur islamist newrecur1 territory strongstart anostart oilstart youthstartap muslimajstart lngdppcstart lnpopstart anostart foreignfighter duration intensitylevel leftist nonislamist pko ca govv rebv lowcease anocracy lngdppc lnpop govmilsupport number_group secsup_govgov rebext
//outreg2 using appendix-A2.doc, replace sum(log) keep (firstrecur newrecur1 islamist territory strongstart anostart oilstart youthstartap muslimajstart lngdppcstart lnpopstart anostart foreignfighter duration intensitylevel leftist nonislamist pko ca govv rebv lowcease anocracy lngdppc lnpop govmilsupport number_group secsup_govgov rebext)
//reload data after this line


************************************************
* FIGURE 2
************************************************

*produce a plot with two survivor functions: with and without islamist, please note: without strata

set scheme plottig
sts graph, legend (cols(1)) by(islamist) ci 
*minor adjustments made manually, e.g.  set background region to grayscale 15, set labels*


************************************************
* TABLE 1
************************************************

//Model 1 see do-file on termination//

stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
stcox islamist $X1, cluster(dyadid) strata(order)  nolog
outreg using recurrence-t1.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*Model 3* NOTE: Alt DV: New groups
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

stcox islamist $X1, cluster(dyadid) strata(order)  nolog
outreg using recurrence-t1.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE 2
************************************************

//Model 1 see do-file on termination//

stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2* foreign fighter & govmilsupport
stcox islamist $X1 foreignfighter govmilsupport, cluster(dyadid) strata(order)  nolog
outreg using recurrence-t2.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 foreignfighter govmilsupport, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*Model 3* NOTE: DV: New groups
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

stcox islamist $X1 foreignfighter govmilsupport, cluster(dyadid) strata(order)  nolog
outreg using recurrence-t2.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 foreignfighter govmilsupport, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE 3
************************************************

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*violations, leftist interacted with log of time
capture drop sch* sca*
stcox leftist $X1 govmilsupport foreignfighter, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

gen leftistt=leftist*ln(_t)

*Model 2*
stcox leftist leftistt $X1 foreignfighter govmilsupport, cluster(dyadid) strata(order)  nolog
outreg using recurrence-t3.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox leftist leftistt $X1 govmilsupport foreignfighter, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox leftist $X1 foreignfighter govmilsupport, cluster(dyadid) strata(order)  nolog
outreg using recurrence-t3.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox leftist $X1 govmilsupport foreignfighter, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE 4
************************************************

*termination type and PKO*

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 1* 
stcox islamist $X1 pko ca govv rebv lowcease if outcome !=. , cluster(dyadid) strata(order) nolog 
outreg using recurrence-t4.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 pko ca govv rebv lowcease if outcome !=. , cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 2*
stcox islamist $X1 pko ca govv rebv lowcease if outcome !=., cluster(dyadid) strata(order) nolog
outreg using recurrence-t4.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 pko ca govv rebv lowcease if outcome !=. , cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************************************************************************************************************************************************

****ROBUSTNESS****

************************************************************************************************************************************************************************************


************************************************
* TABLE A3
************************************************

//See do-file on termination//


************************************************
* TABLE A4
************************************************

*alternative survival models*

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 1* weibull instead of cox, without strata
streg islamist $X1, dist(weibull) cluster(dyadid) nolog
outreg using appendix-A4a.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

streg islamist $X1, dist(weibull) cluster(dyadid) strata(order) nolog

*Model 2* exponential instead of cox, without strata
streg islamist $X1, dist(exponential) cluster(dyadid) nolog
outreg using appendix-A4b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

streg islamist $X1, dist(exponential) cluster(dyadid) strata(order) nolog


************************************************
* TABLE A5
************************************************

*alternative survival models*

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 1* weibull instead of cox, without strata
streg islamist $X1, dist(weibull) nolog
outreg using appendix-A5a.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

streg islamist $X1, dist(weibull) cluster(dyadid) strata(order) nolog

*Model 2* exponential instead of cox, without strata
streg islamist $X1, dist(exponential) cluster(dyadid) nolog
outreg using appendix-A5b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

streg islamist $X1, dist(exponential) cluster(dyadid) strata(order) nolog


************************************************
* TABLE A6
************************************************

//See separate dataset and do-file, two-year-gap//


************************************************
* TABLE A7a - Foreign fighters
************************************************

//Model 1, see do-file on termination//

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
gen islamistff=islamist*foreignfighter

stcox islamist $X1 islamistff foreignfighter govmilsupport, cluster(dyadid) strata(order) nolog 
outreg using appendix-A7a-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 islamistff foreignfighter govmilsupport, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

streg islamist##foreignfighter $X1  govmilsupport, dist(weibull) cluster(dyadid) nolog

*lrtest*
stcox i.islamist i.foreignfighter $X1 govmilsupport, strata(order) nolog 
estimates store main

stcox i.islamist##i.foreignfighter $X1 govmilsupport, strata(order) nolog 
estimates store inter

lrtest main

*wald*
stcox i.islamist##i.foreignfighter $X1 govmilsupport, strata(order) nolog 

test 1.islamist#0.foreignfighter=1.islamist#1.foreignfighter


*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox islamist $X1 islamistff foreignfighter govmilsupport, cluster(dyadid) strata(order) nolog
outreg using appendix-A7a-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) append

capture drop sch* sca*
stcox islamist $X1 islamistff foreignfighter govmilsupport, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*lrtest*
stcox i.islamist i.foreignfighter $X1 govmilsupport, strata(order) nolog 
estimates store main

stcox i.islamist##i.foreignfighter $X1 govmilsupport, strata(order) nolog 
estimates store inter

lrtest main

*wald*
stcox i.islamist##i.foreignfighter $X1 govmilsupport, strata(order) nolog 

test 1.islamist#0.foreignfighter=1.islamist#1.foreignfighter


************************************************
* TABLE A7b - Foreign fighters is absent
************************************************

**Model 2 and 3, when Foreign Fighter is 0*
gen foreignfighter0=.
recode foreignfighter0 .=1 if foreignfighter==0
recode foreignfighter0 .=0 if foreignfighter==1
tab foreignfighter0 foreignfighter

gen islamistff0=islamist*foreignfighter0

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
stcox islamist $X1 islamistff0 foreignfighter0 govmilsupport, cluster(dyadid) strata(order) nolog
outreg using appendix-A7b-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox islamist $X1 islamistff0 foreignfighter0 govmilsupport, cluster(dyadid) strata(order) nolog
outreg using appendix-A7b-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) append


************************************************
* TABLE A7c - Govmilsupport
************************************************

//Model 1, see do-file on termination//

*violations, strongstart interacted with time
gen strongstartt=strongstart*(_t)
gen islamistgovmil=islamist*govmilsupport

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
stcox islamist $X1 islamistgovmil foreignfighter govmilsupport strongstartt, cluster(dyadid) strata(order) nolog
outreg using appendix-A7c-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 islamistgovmil foreignfighter govmilsupport strongstartt, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*lrtest*
stcox i.islamist i.govmilsupport $X1 foreignfighter strongstartt, strata(order) nolog 
estimates store main

stcox i.islamist##i.govmilsupport $X1 foreignfighter strongstartt, strata(order) nolog 
estimates store inter

lrtest main

*wald*
stcox i.islamist##i.govmilsupport $X1 foreignfighter strongstartt, strata(order) nolog 

test 1.islamist#0.govmilsupport=1.islamist#1.govmilsupport


*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox islamist $X1 islamistgovmil foreignfighter govmilsupport, cluster(dyadid) strata(order) nolog
outreg using appendix-A7c-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) append

capture drop sch* sca*
stcox islamist $X1 islamistgovmil foreignfighter govmilsupport, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*lrtest*
stcox i.islamist i.govmilsupport $X1 foreignfighter, strata(order) nolog 
estimates store main

stcox i.islamist##i.govmilsupport $X1 foreignfighter, strata(order) nolog 
estimates store inter

lrtest main

*wald*
stcox i.islamist##i.govmilsupport $X1 foreignfighter, strata(order) nolog 

test 1.islamist#0.govmilsupport=1.islamist#1.govmilsupport


************************************************
* TABLE A7d - Govmilsupport absent
************************************************


**Model 2 and 3, when Govmil support is 1*
gen govmilsupport0=.
recode govmilsupport0 .=1 if govmilsupport==0
recode govmilsupport0 .=0 if govmilsupport==1
tab govmilsupport0 govmilsupport

gen islamistgovmil0=islamist*govmilsupport0

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
stcox islamist $X1 islamistgovmil0 foreignfighter govmilsupport0 strongstartt, cluster(dyadid) strata(order) nolog
outreg using appendix-A7d-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox islamist $X1 islamistgovmil0 foreignfighter govmilsupport0, cluster(dyadid) strata(order) nolog
outreg using appendix-A7d-recur.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) append


************************************************
* TABLE A8
************************************************

//Model 1, see do-file on termination//

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*

*violations, secsup_govgov interacted with log of time
capture drop sch* sca*
stcox islamist $X1 secsup_govgov rebext, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

gen secsup_govgovt=secsup_govgov*ln(_t)

capture drop sch* sca*
stcox islamist $X1 secsup_govgov rebext secsup_govgovt, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

stcox islamist $X1 secsup_govgov rebext secsup_govgovt, cluster(dyadid) strata(order) nolog
outreg using appendix-A8b, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

*Model 3*

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

stcox islamist $X1 secsup_govgov rebext, cluster(dyadid) strata(order) nolog
outreg using appendix-A8b, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 secsup_govgov rebext, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE A9
************************************************

*gdp, population and anocracy*

//See do-file on termination//


************************************************
* TABLE A10
************************************************

*gdp, population and anocracy*

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 1*
stcox islamist $X1 lngdppcstart lnpopstart, cluster(dyadid) strata(order) nolog
outreg using appendix-A10, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 lngdppcstart lnpopstart, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 2*
stcox islamist $X1 anostart, cluster(dyadid) strata(order) nolog
outreg using appendix-A10, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 anostart, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 3*
stcox islamist $X1 lngdppc lnpop, cluster(dyadid) strata(order) nolog
outreg using appendix-A10.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 lngdppc lnpop, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 4*
stcox islamist $X1 anocracy, cluster(dyadid) strata(order) nolog
outreg using appendix-A10.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 anocracy, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE A11
************************************************

*gdp, population and anocracy*

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 1*
stcox islamist $X1 lngdppcstart lnpopstart, cluster(dyadid) strata(order) nolog
outreg using appendix-A11.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 lngdppcstart lnpopstart, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 2*
stcox islamist $X1 anostart, cluster(dyadid) strata(order) nolog
outreg using appendix-A11.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 anostart, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 3*
stcox islamist $X1 lngdppc lnpop, cluster(dyadid) strata(order) nolog
outreg using appendix-A11.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 lngdppc lnpop, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 4*
stcox islamist $X1 anocracy, cluster(dyadid) strata(order) nolog
outreg using appendix-A11.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 anocracy, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE A12
************************************************

//Model 1-3 see do-file on termination//

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 4* leftist

*violations, leftist interacted with log of time
capture drop sch* sca*
stcox leftist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

capture drop sch* sca*
stcox leftist leftistt $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

stcox leftist leftistt $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A12b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

*alternative survial models*

*Model 1* weibull instead of cox, without strata
streg leftist $X1, dist(weibull) cluster(dyadid) nolog
//with strata does not converge//

*Model 2* exponential instead of cox, without and with strata
streg leftist $X1, dist(exponential) cluster(dyadid) nolog
streg leftist $X1, dist(exponential) cluster(dyadid) strata(order) nolog
  
*Model 5* muslim identity
stcox islamist muslimid $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A12b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist muslimid $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 6* nonislamist
stcox nonislamist $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A12b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox nonislamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE A13
************************************************

*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 4*
stcox leftist $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A13.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox leftist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*weibull instead of cox, without and with strata
streg leftist $X1, dist(weibull) cluster(dyadid) nolog
streg leftist $X1, dist(weibull) cluster(dyadid) strata(order) nolog

*exponential instead of cox, without and with strata
streg leftist $X1, dist(exponential) cluster(dyadid) nolog
streg leftist $X1, dist(exponential) cluster(dyadid) strata(order) nolog

*Model 5*
stcox islamist muslimid $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A13.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist muslimid $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*Model 6*
stcox nonislamist $X1, cluster(dyadid) strata(order) nolog
outreg using appendix-A13.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox nonislamist $X1, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE A14
************************************************

*Model 1*
//See do-file on termination//

*number_group*

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
stcox islamist $X1 number_group, cluster(dyadid) strata(order) nolog
outreg using appendix-A14b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox number_group $X1 , cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox islamist $X1 number_group, cluster(dyadid) strata(order) nolog
outreg using appendix-A14b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox number_group $X1 , cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

stcox islamist $X1 number_group govmilsupport foreignfighter, cluster(dyadid) strata(order) nolog

capture drop sch* sca*
stcox number_group govmilsupport foreignfighter $X1 , cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************
* TABLE A15
************************************************

*duration and intensity*

*Model 1*
//See do-file on termination//

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 2*
*violations, strong interacted with log of time
capture drop sch* sca*
stcox islamist $X1 duration intensitylevel, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*gen strongstartt=strongstart*(_t)

stcox islamist $X1 duration intensitylevel strongstartt, cluster(dyadid) strata(order) nolog
outreg using appendix-A15b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 duration intensitylevel strongstartt, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 3*
stcox islamist $X1 duration intensitylevel, cluster(dyadid) strata(order) nolog
outreg using appendix-A15b.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 duration intensitylevel, cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail

*high-intensity and low-intensity conflicts*
unique dyadid if intensity==2 & islamist==1
unique dyadid if islamist==1
*6 out of 53, 11%

unique dyadid if intensity==2 & islamist==0
unique dyadid if islamist==0
*41 out of 314, 13%


************************************************
* TABLE A16
************************************************

*different forms of peace agreements
*termination type and PKO*

*Recurrence*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(firstrecur==1) exit(time .)

*Model 1* PKO
stcox islamist $X1 pko ca panotfull pafull rebv lowcease if outcome !=., cluster(dyadid) strata(order) nolog
outreg using appendix-A16.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) replace

capture drop sch* sca*
stcox islamist $X1 pko ca panotfull pafull rebv lowcease if outcome !=., cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


*Recurrence-new*
stset end_of_segment, id(dyadid) origin(time first_year_of_peace) enter(time start_of_segment) failure(newrecur1==1) exit(time .)

*Model 2* PKO
stcox islamist $X1 pko ca panotfull pafull rebv lowcease if outcome !=., cluster(dyadid) strata(order) nolog
outreg using appendix-A16.doc, se var hr starlevels(10 5 1) sigsymbols(+,*,**) note (Robust standard errors in parentheses clustered on dyad.) merge

capture drop sch* sca*
stcox islamist $X1 pko ca panotfull pafull rebv lowcease if outcome !=., cluster(dyadid) strata(order) scaledsch(sca*) schoenfeld(sch*) nohr
stphtest, rank detail


************************************************************************************************************************************************************************************
************************************************************************************************************************************************************************************
